package com.my.rabbitmq.seven;

import com.my.utils.RabbitMQUtils;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2023/11/30 15:42
 */
// 死信队列 生产者
public class Producer {

    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();
        // 死信消息 设置TTL时间 time to live 
        // 单位是ms 10000ms = 10s
        AMQP.BasicProperties properties = 
                new AMQP.BasicProperties().builder().expiration("10000").build();
        for (int i = 0; i < 11; i++) {
            String message = "info" + i;
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, message.getBytes());
        }
    }
    
}
